<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8" />
        <title>账号登录-{eyou:global name='web_name' /}</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
        <link href="{eyou:global name='web_cmspath' /}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        {eyou:static file="users/skin/css/basic.css" /}
        {eyou:static file="users/skin/css/login.css" /}
        {eyou:static file="users/skin/verify/verify.css" /}
        {eyou:include file="users/skin/css/diy_css.htm"/}
        {eyou:static file="/public/static/admin/font/css/iconfont.css"/}
        {eyou:static file="/public/static/common/js/jquery.min.js"/}
        {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
        {eyou:static file="users/skin/js/global.js" /}
        {eyou:static file="users/skin/verify/verify.js" /}
    </head>

    <body class="login">
        <div class="container">
            <header class="head">
                <div class="head-l">
                    <a class="logo" href="{eyou:global name='web_cmsurl' /}"><img src="{eyou:global name='web_pc_logo'/}"></a>
                </div>
                <div class="head-r">
                    <div class="serve"><img src="{eyou:static file='users/skin/images/hand_serve1.png'}">品种齐全</div>
                    <div class="serve"><img src="{eyou:static file='users/skin/images/hand_serve2.png'}">低价畅选</div>
                    <div class="serve"><img src="{eyou:static file='users/skin/images/hand_serve1.png'}">正品行货</div>
                </div>
            </header>
        </div>

        <div class="login-box-bg container">
            <div class="tab_con">
                <div class="tab_con_box phone_con_box" style="display: block;">
                    <div class="title"> 快速登录/注册 </div>
                    {eyou:static file="/public/static/common/js/mobile_login.js"/}
                    <form action="" name='theMobileForm' id="theMobileForm" method="post">
                        <div class="form-group phone">
                            <span class="number">+86</span>
                            <input type="text" name="mobile" id="mobile" class="form-control" placeholder="请输入手机号" maxlength="11" autocomplete="off" required/>
                        </div>
                        <div class="form-group verificat">
                            <input type="text" name="mobile_code" id="mobile_code" class="form-control" placeholder="请输入验证码" autocomplete="off" required/>
                            <span class="code" id="mobile_code_button" onclick="get_xx_code('获取验证码');">获取验证码</span>
                        </div>
                        <div class="protocol">
                            <label class="checkbox-xi">
                                <input type="checkbox" name="agreement" value="1">
                                <span class="agree">我已阅读并同意<a href="javascript:void(0);" onclick="reg_agreement();">《<span id="reg_agreement_title">{$agreement[1]['title']|default='隐私协议'}</span>》</a></span>
                            </label>
                        </div>
                        <input type="hidden" name="loginsynreg" value="1" />
                        <input type="hidden" name="website" value="website" />
                        <input type="hidden" name="referurl" value="{$referurl}" />
                        <input type="hidden" name="__mobile_1_token__" value="{$Request.token.__mobile_1_token__}" />
                        <input id="mobile_submitButton" type="button" onclick="checkMobileUserLogin1649732103();" class="login-btn" value="登录/注册"/>
                    </form>
                    <div class="login-tab">
                        <span class="tab_login_mode" id="pwd-login" data-index="1">账号登录</span>
                        {eyou:if condition="!empty($weapp_wxlogin)"}
                        <span><a href="javascript:void(0);" onclick="wxLogin(this);" data-url='{$RootDir}/index.php?m=plugins&c=WxLogin&a=login'>微信登录</a></span>
                        {/eyou:if}
                    </div>
                </div>
                <div class="tab_con_box pwd_con_box">
                    <div class="title"> 账号登录 </div>
                    <form action="" name='theForm' id="theForm" method="post">
                        <div class="form-group phone">
                            <span class="number">+86</span>
                            <input id="username" type="text" name="username" value="" required class="form-control" placeholder="请输入手机号" maxlength="11" autocomplete="off" />
                        </div>
                        <div class="form-group pwd">
                            <input type="password" name="password" value="" id="password" required class="form-control" placeholder="请输入密码" autocomplete="off" />
                        </div>
                        <div class="protocol">
                            <label class="checkbox-xi">
                                <input type="checkbox" name="agreement" value="1">
                                <span class="agree">我已阅读并同意<a href="javascript:void(0);" onclick="reg_agreement();">《<span id="reg_agreement_title">{$agreement[1]['title']|default='隐私协议'}</span>》</a></span>
                            </label>
                        </div>
                        <input type="hidden" name="referurl" value="{$referurl}" />
                        <input type="hidden" name="website" value="website" />
                        <input id="submitButton" name="submit" type="button" class="login-btn" value="登录"/>
                    </form>
                    <div class="login-tab">
                        <span class="tab_login_mode current" id="phone-login" data-index="0">手机登录</span>
                        {eyou:if condition="!empty($weapp_wxlogin)"}
                        <span><a href="javascript:void(0);" onclick="wxLogin(this);" data-url='{$RootDir}/index.php?m=plugins&c=WxLogin&a=login'>微信登录</a></span>
                        {/eyou:if}
                    </div>
                </div>
            </div>
        </div>

        <div class="footer container">
            <p>{eyou:global name='web_copyright'/}</p>
            <p>{eyou:global name='web_recordnum'/}</p>
        </div>
        
        <script type="text/javascript">

            function reg_agreement()
            {
                var iframes = layer.open({
                    type: 2,
                    skin:'layui-layer-xieyi',
                    title: "{$agreement[1]['title']|default='《隐私协议》'}",
                    fixed: true, //不固定
                    shadeClose: true,
                    btnAlign:'c',
                    closeBtn: 3,
                    btn: ['确定'], //按钮
                    // maxmin: true, //开启最大化最小化按钮
                    area: ['60%', '80%'],
                    content: "{:url('user/Users/reg_agreement')}"
                });
            }

            function wxLogin(obj)
            {
                var index = $(".login-tab span.current").attr('data-index');
                if (0 == index) {
                    if (1 != $('#theMobileForm input[name=agreement]:checked').val()) {
                        var reg_agreement_title = $('#theMobileForm #reg_agreement_title').html();
                        layer.msg('请确认阅读'+reg_agreement_title, {time: 1500});
                        return false;
                    }
                }else if(1 == index){
                    if (1 != $('#theForm input[name=agreement]:checked').val()) {
                        var reg_agreement_title = $('#theForm #reg_agreement_title').html();
                        layer.msg('请确认阅读'+reg_agreement_title, {time: 1500});
                        return false;
                    }
                }

                var url = $(obj).data('url');
                url = url + '&iframe=1&referurl=' + encodeURIComponent(window.location.href);
                //iframe窗
                var wxLogin_iframes = layer.open({
                    type: 2,
                    title: '微信登录',
                    shadeClose: false,
                    maxmin: false, //开启最大化最小化按钮
                    area: ['500px', '460px'],
                    content: url
                });
                // newWinOpen(url, '微信登录');
            }

            //切换账号登录与手机号登录
            $(".tab_login_mode").click(function(){
                var index = $(this).attr('data-index');
                $(".tab_login_mode").each(function(){
                    $(this).removeClass('current');
                });
                $(".tab_con_box").each(function(i,v){
                    if (index == i){
                        $(this).css('display','block');
                    } else{
                        $(this).css('display','none');
                    }
                });
                $(this).addClass('current');
            });

            $(document).keydown(function(event) {
                if (event.keyCode == 13) {
                    var index = $(".login-tab span.current").attr('data-index');
                    if (0 == index) {
                        checkMobileUserLogin1649732103();
                    }else if(1 == index){
                        $('input[name=submit]').trigger("click");
                    }
                }
            });

            function code_countdown(){
                // 倒计时
                var setTime;
                var time = 120;
                setTime = setInterval(function() {
                    if(0 >= time) {
                        clearInterval(setTime);
                        return false;
                    }

                    time--;
                    $("#theMobileForm #mobile_code_button").html(time + '秒').attr('disabled', 'disabled');
                    if(time == 0) $("#theMobileForm #mobile_code_button").html('重新获取').removeAttr("disabled");
                }, 1000);
            }

            function get_xx_code(title) {

                var disabled = $("#theMobileForm #mobile_code_button").attr('disabled');
                if (disabled == 'disabled') {
                    return false;
                }

                var mobile = $("input[name=mobile]").val();
                // 手机号是否为空
                if (!mobile) {
                    $("input[name=mobile]").focus();
                    var msg = $('input[name=mobile]').attr('placeholder');
                    if (!msg) {
                        msg = '请输入手机号';
                    }
                    layer.msg(msg, {time: 1500});
                    return false;
                }

                // 手机格式不正确
                var reg = /^1[0-9]{10}$/i;
                if (!reg.test(mobile)) {
                    $("input[name=mobile]").focus();
                    layer.msg('请输入正确的手机号码！', {time: 1500});
                    return false;
                }

                if (1 != $('#theMobileForm input[name=agreement]:checked').val()) {
                    var reg_agreement_title = $('#theMobileForm #reg_agreement_title').html();
                    layer.msg('请确认阅读'+reg_agreement_title, {time: 1500});
                    return false;
                }

                var url = '{$RootDir}/index.php?m=user&c=Users&a=codepic';
                //iframe窗
                layer.open({
                    type: 2,
                    title: title,
                    shadeClose: false,
                    maxmin: false, //开启最大化最小化按钮
                    area: ['360px', '276px'],
                    content: url
                });
            }

            $(function() {
                $('input[name=submit]').on('click', function() {

                    if (1 != $('#theForm input[name=agreement]:checked').val()) {
                        var reg_agreement_title = $('#theForm #reg_agreement_title').html();
                        layer.msg('请确认阅读'+reg_agreement_title, {time: 1500});
                        return false;
                    }

                    var username = $('#theForm input[name=username]');
                    var password = $('#theForm input[name=password]');

                    if (username.val() == '') {
                        var msg = username.attr('placeholder');
                        if (!msg) {
                            msg = '请输入手机号';
                        }
                        layer.msg(msg, {
                            time: 1500
                        });
                        username.focus();
                        return false;
                    }

                    if (password.val() == '') {
                        var msg = password.attr('placeholder');
                        if (!msg) {
                            msg = '请输入密码';
                        }
                        layer.msg(msg, {
                            time: 1500
                        });
                        password.focus();
                        return false;
                    }

                    var formData = $('#theForm').serialize();
                    {$pwdJsCode|default=''}
                    layer_loading('正在处理');
                    $.ajax({
                        // async:false,
                        url: "{eyou:url link='user/Users/login' /}",
                        data: formData,
                        type: 'post',
                        dataType: 'json',
                        success: function(res) {
                            if (1 == res.code) {
                                if (5 == res.data.status) {
                                    layer.alert(res.msg, {
                                        icon: 5,
                                        title: false,
                                        closeBtn: false
                                    }, function() {
                                        window.location.href = res.url;
                                    });
                                } else {
                                    window.location.href = res.url;
                                }
                            } else {
                                layer.closeAll();
                                if (2 == res.data.status) {
                                    showErrorAlert(res.msg, 4);
                                } else {
                                    layer.msg(res.msg, {
                                        icon: 5,
                                        time: 1500
                                    });
                                }
                            }
                        },
                        error: function(e) {
                            layer.closeAll();
                            showErrorAlert(e.responseText);
                        }
                    });
                });
            });
        </script>
    </body>
</html>